| Conditions | 1 |
| Paths | 1 |
| Total Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /** |
||
| 9 | return this.each(function() { |
||
| 10 | |||
| 11 | // cache this selector for further use |
||
| 12 | thisFontPickerCustomControl = this; |
||
|
|
|||
| 13 | |||
| 14 | // hide select box |
||
| 15 | $("select", this).hide(); |
||
| 16 | |||
| 17 | // show fancy content |
||
| 18 | $(".fancyDisplay", this).show(); |
||
| 19 | |||
| 20 | // add event listeners to fancy display |
||
| 21 | $(".fancyDisplay ul li").on("click", function(event){ |
||
| 22 | // get index of clicked element |
||
| 23 | var index = $(".fancyDisplay ul li", thisFontPickerCustomControl).index(this), |
||
| 24 | clicked = $(this), |
||
| 25 | parent = clicked.closest('.fancyDisplay'); |
||
| 26 | |||
| 27 | parent.find('.font-choice').removeClass('selected'); |
||
| 28 | |||
| 29 | // unselect all options |
||
| 30 | $('select option', thisFontPickerCustomControl).removeAttr('selected'); |
||
| 31 | |||
| 32 | clicked.addClass('selected'); |
||
| 33 | // select new element |
||
| 34 | // simulate a change |
||
| 35 | $('select :nth-child('+(index+1)+')', thisFontPickerCustomControl).attr('selected', 'selected').change(); |
||
| 36 | }); |
||
| 37 | |||
| 38 | }); |
||
| 39 | |||
| 43 |